jQuery.support.cors = true;

function sendRequest(request, success, error) {
    request.data.userId = $userId;

    let x = request.url.indexOf('?') === -1 ? request.url + '?userId=' + $userId : request.url + '&userId=' + $userId;

    $.ajax({
        headers: {
            "token": $token,
        },
        url: $baseUrl + x,
        data: request.data,
        // dataType: "json",
        // contentType: request.contentType || 'application/x-www-form-urlencoded; charset=UTF-8',
        contentType: request.contentType || 'application/json;charset=UTF-8',
        method: request.method || 'GET',
        async: request.async || true,
        timeout: request.timeout || 10000,
        success(data) {
            success && success(data);
        },
        error(data) {
            error && error(data);
            error || console.error(data.responseJSON);
            // error || mui.alert("请稍后再试!")
            // console.log("清稍后再试");
            // alert("清稍后再试");
        }

    });

}
